package com.ruoyi.zxjd.work.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.zxjd.work.domain.WorkProgress;
import com.ruoyi.zxjd.work.domain.WorkTemplateTable9;
import com.ruoyi.zxjd.work.domain.bo.WorkProgressBO;
import com.ruoyi.zxjd.work.service.IWorkProgressService;
import com.ruoyi.zxjd.work.service.IWorkTemplateTable9Service;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 宜宾市纪委监委信访举报转办件办理情况反馈Controller
 * 
 * @author zj
 * @date 2021-03-20
 */
@Controller
@RequestMapping("/work/templatetable9")
public class WorkTemplateTable9Controller extends BaseController {
    private String prefix = "work/templatetable9";

    @Autowired
    private IWorkTemplateTable9Service workTemplateTable9Service;

    @Autowired
    private IWorkProgressService workProgressService;

    @RequiresPermissions("work:templatetable9:view")
    @GetMapping()
    public String templatetable9() {
        return prefix + "/templatetable9";
    }

    /**
     * 查询宜宾市纪委监委信访举报转办件办理情况反馈列表
     */
    @RequiresPermissions("work:templatetable9:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(WorkTemplateTable9 workTemplateTable9) {
        startPage();
        List<WorkTemplateTable9> list = workTemplateTable9Service.selectWorkTemplateTable9List(workTemplateTable9);
        return getDataTable(list);
    }

    /**
     * 导出宜宾市纪委监委信访举报转办件办理情况反馈列表
     */
    @RequiresPermissions("work:templatetable9:export")
    @Log(title = "宜宾市纪委监委信访举报转办件办理情况反馈", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(WorkTemplateTable9 workTemplateTable9) {
        List<WorkTemplateTable9> list = workTemplateTable9Service.selectWorkTemplateTable9List(workTemplateTable9);
        ExcelUtil<WorkTemplateTable9> util = new ExcelUtil<WorkTemplateTable9>(WorkTemplateTable9.class);
        return util.exportExcel(list, "templatetable9");
    }

    /**
     * 新增宜宾市纪委监委信访举报转办件办理情况反馈
     */
    @GetMapping("/add")
    public String add() {
        return prefix + "/add";
    }

    /**
     * 新增保存宜宾市纪委监委信访举报转办件办理情况反馈
     */
    @RequiresPermissions("work:templatetable9:add")
    @Log(title = "宜宾市纪委监委信访举报转办件办理情况反馈", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(WorkProgressBO workProgressBO) {
        return toAjax(workTemplateTable9Service.insertWorkTemplateTable9(workProgressBO));
    }

    /**
     * 修改宜宾市纪委监委信访举报转办件办理情况反馈
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap) {
        WorkTemplateTable9 workTemplateTable9 = workTemplateTable9Service.selectWorkTemplateTable9ById(id);
        Long progressId = workTemplateTable9.getProgressId();
        WorkProgress workProgress = workProgressService.selectWorkProgressById(progressId);
        mmap.put("workTemplateTable9", workTemplateTable9);
        mmap.put("workProgress", workProgress);
        return prefix + "/edit";
    }

    /**
     * 修改保存宜宾市纪委监委信访举报转办件办理情况反馈
     */
    @RequiresPermissions("work:templatetable9:edit")
    @Log(title = "宜宾市纪委监委信访举报转办件办理情况反馈", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(WorkTemplateTable9 workTemplateTable9) {
        return toAjax(workTemplateTable9Service.updateWorkTemplateTable9(workTemplateTable9));
    }

    /**
     * 删除宜宾市纪委监委信访举报转办件办理情况反馈
     */
    @RequiresPermissions("work:templatetable9:remove")
    @Log(title = "宜宾市纪委监委信访举报转办件办理情况反馈", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        return toAjax(workTemplateTable9Service.deleteWorkTemplateTable9ByIds(ids));
    }

    /**
     * 删除宜宾市纪委监委信访举报转办件办理情况反馈
     */
    @RequiresPermissions("work:templatetable9:remove")
    @Log(title = "宜宾市纪委监委信访举报转办件办理情况反馈", businessType = BusinessType.DELETE)
    @GetMapping("/remove")
    @ResponseBody
    public AjaxResult removeByGet(String ids) {
        return toAjax(workTemplateTable9Service.deleteWorkTemplateTable9ByIds(ids));
    }
}
